package tiltmaze.solver;

import java.util.ArrayList;

/**
 * Class representing a path of the ball in the maze.
 * @author Juraj Nižnan
 */
public class MazePath {

    ArrayList<Integer> path = new ArrayList<Integer>();
    Vertex lastVertex;
    int checkpointsCollected;

    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final MazePath other = (MazePath) obj;
        if (this.lastVertex != other.lastVertex && (this.lastVertex == null || !this.lastVertex.equals(other.lastVertex))) {
            return false;
        }
        if (this.checkpointsCollected != other.checkpointsCollected) {
            return false;
        }
        return true;
    }

    @Override
    public int hashCode() {
        return this.checkpointsCollected;
    }

    @Override
    public String toString() {
        String ret = path.size() + ": ";
        for (int i = 0; i < path.size(); i++) {
            ret += path.get(i);
        }
        return ret;
    }

    public String getStateNodeLabel(){
        return lastVertex.position.toString() + ":" + checkpointsCollected;
    }

}
